*** Stata 15 reproduction code for

*Mader, Matthias & Harald Schoen.
*The European refugee crisis, party competition, and voters’ responses in Germany
*West European Politics


*** Prepare data
******************
*	cleaned data available for download; do files available upon request; 
*	do "0000_Prepare_panel_data.do" // creates DATA_wide.dta, DATA_long.dta
*	do "000_Prepare_tracking_data.do" // creates DATA_Figure1.dta


*** Main text
***************

*** p.xx: "1317 respondents participated in all ten waves"
	// Filter for respondents who participated in all relevant waves (numbering in dataset: w1, w2, w6, w7, w9, w10, w11, w13, w16, w17)
	use "DATA_wide.dta", clear
	tab filter1
	
*** Table 2: Change in immigration and welfare attitudes (column percentages)
*** Table 3: Change in perceived party positions and policy distances
	do 01_Table2_Table3.do


*** Endnote 7 on CDU and CSU perceptions
	use "DATA_Figure1.dta", clear

	pwcorr immi_cdu immi_csu [aw = weight] if track <= 28 // Tracking 28 was conducted at the beginning of the so-called refugee crisis (in June 2015)
	pwcorr immi_cdu immi_csu [aw = weight] if track < 28
	pwcorr immi_cdu immi_csu [aw = weight] if track == 20
	pwcorr immi_cdu immi_csu [aw = weight] if track == 21
	pwcorr immi_cdu immi_csu [aw = weight] if track == 24
	pwcorr immi_cdu immi_csu [aw = weight] if track == 28

	gen pdiff = immi_cdu - immi_csu
	gen pdiff_d = .
	replace pdiff_d = 0 if (pdiff > 1 & pdiff < 8) | pdiff < -1
	replace pdiff_d = 1 if pdiff <= 1 & pdiff >= -1
	fre pdiff_d [aw = weight] if track <= 28
	fre pdiff_d [aw = weight] if track < 28
	fre pdiff_d [aw = weight] if track == 20
	fre pdiff_d [aw = weight] if track == 21
	fre pdiff_d [aw = weight] if track == 24
	fre pdiff_d [aw = weight] if track == 28

*** Figure 1: Immigration salience, perceived party positions, and attitudes, 2013-2017
	do 02_Figure1.do

*** Figure 2: Effects of prior party identification on change in attitudes toward immigration
	do 03_Figure2.do

*** Figure 3: Effects of change in absolute policy distance on change in party approval
	do 04_Figure3.do

*** Figure 4: Effects of pre-crisis immigration attitude on change in party and leader approval
	do 05_Figure4.do
	
*** Figure 5: Effects of change in absolute distance to the CDU and of pre-crisis immigration attitude on change in vote choice and party identification
	do 06_Figure5.do
	
	
*** Appendix
**************

*** Table A3-1: Attitude stability in the 2013 campaign panel 
	do 07_Table_A3_1.do
	
*** Figure A3-1: Figure A3-1: DK/RF responses to party position items
	do 08_Figure_A3_1.do

*** Figure A3-2: Mean absolute immigration policy distance in groups differing in prior immigration attitude
	do 09_Figure_A3_2.do
	
*** Figure A4-1: Effects of change in absolute distance to the CDU on change in vote choice and party identity
	do 10_Figure_A4_1.do
	
*** Figure A4-2: Effects of prior immigration attitude on vote choice and party identity
	do 11_Figure_A4_2.do
	
*** Figure A4-3: Party identification after the crisis among prior CDU identifiers
	do 12_Figure_A4_3.do
	
*** Tables reported in A5
	// unformatted tables are produced when running 03_Figure2.do, 04_Figure3.do, 05_Figure4.do, 06_Figure5.do
